// 实例上的属性，原型上的方法 。类的属性和类的方法
class Greeter {
    greeting: string;
    constructor(message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}
// 继承，用继承扩展现有的类，通过抽离父类的方式来事项子类的复用
class Greeter1 extends Greeter {
    constructor() {
        super('123qqqq')
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}
let greeter = new Greeter("world");

// 修饰符
// public  公共属性：都可用，自身，子类和实例
// private 私有属性：自身可用
// protected 受保护的属性 自身可用，子类可用
// readonly 属性只读，只能出现在属性和索引上
class Animal {
    // public name: string;
    age: number;//默认public
    // public constructor(theName: string) {
    //     this.name = theName
    // }
    //简写
    constructor(private name: string) {
        this.name = name
    }
    public move(distanceInMeters: number) {
        console.log(`${this.name}`);

    }
}

// get() set()
let passcode = "secret passcode";

class Employee {
    private _fullName: string;

    get fullName(): string {
        return this._fullName;
    }

    set fullName(newName: string) {
        if (passcode && passcode == "secret passcode") {
            this._fullName = newName;
        }
        else {
            console.log("Error: Unauthorized update of employee!");
        }
    }
    static a: number = 123,
    static b(a: number, b: number): number {
        return a + b;
    }
}

let employee = new Employee();
employee.fullName = "Bob Smith";
if (employee.fullName) {
    alert(employee.fullName);
}


// 抽象类
// 抽象类中的抽象方法必须在子类中实现
// 抽象类是不能被实例化的
abstract class Animal1 {
    abstract makeSound(): void;
    move(): void {
        console.log('roaming the earch...');
    }
}